import React, {useContext} from 'react';
import {View, Platform} from 'react-native';
import dayjs from 'dayjs';
import {useNavigation} from '@react-navigation/native';
import {
  HeaderTitle,
  HeaderBackButton,
  Header as HeaderRNE,
} from '@react-navigation/elements';
import globalStyle from '@/style/global.less';
export default ({children, headerRight = () => <></>}) => {
  const navigation = useNavigation();
  return (
    <>
      <View
        style={{
          flexShrink: 0,
        }}>
        <HeaderRNE
          headerLeft={() => (
            <HeaderBackButton
              onPress={() => {
                navigation.goBack();
              }}
            />
          )}
          title={<HeaderTitle>{children}</HeaderTitle>}
          headerShadowVisible={true}
          headerStyle={[globalStyle.headerBasic]}
          headerRight={headerRight}
        />
      </View>
      <View style={{height: Platform.OS === 'ios' ? 1 : 3}}></View>
    </>
  );
};
